const crypto = require('crypto');
const router = require('koa-router')();

router.prefix('/api/crypto');

/**
 * md5加密
 */
router.post('/md5', async (ctx, next) => {
    let source = ctx.request.body;
    let hash = crypto.createHash('md5');

    hash.update(source);

    await (ctx.body = {
        result: hash.digest('hex').toUpperCase()
    });
});

module.exports = router;